// 注意我这里只是把代码备份到这里，请不要直接在这里node启动服务器，可以把本文件放到桌面上然后cmd启动
const http = require('http');

const arr = [
    {
        name:'mikaisa',
        age:18,
        info:'none'
    },
    {
        name:'mika',
        age:22,
        info:'none'
    },
    {
        name:'jackson',
        age:13,
        info:'none'
    },
    {
        name:'alan',
        age:44,
        info:'none'
    },
];

http.createServer((req,res)=>{
    const name = new URL('http://localhost:5517'+req.url).searchParams.get('name');
    res.writeHead(200,{
        'Content-Type':'application/json',
        'Access-Control-Allow-Origin':'*'
    });
    
    res.end(JSON.stringify(arr.filter((item)=>item.name == name)));
}).listen(8888);